home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / need.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  1KB  |  77 lines

  1. /* --------------------------------- need.c --------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Often missing common functions.
  8. */
  9.  
  10. #include "fly.h"
  11.  
  12.  
  13. #ifdef NEED_STRICMP
  14. extern int FAR
  15. stricmp (const char *a, const char *b)
  16. {
  17.     int    t;
  18.  
  19.     for (; 0 == (t = toupper(*(Uchar*)a) - toupper(*(Uchar*)b)); ++a,++b) {
  20.         if ('\0' == *a)
  21.             return (0);
  22.     }
  23.     return (t > 0 ? 1 : -1);
  24. }
  25. #endif
  26.  
  27. #ifdef NEED_STRNICMP
  28. extern int FAR
  29. strnicmp (const char *a, const char *b, size_t n)
  30. {
  31.     int    t;
  32.  
  33.     for (; 0 < n; --n, ++a, ++b) {
  34.         if (0 != (t = toupper (*(Uchar *)a) - toupper (*(Uchar *)b)))
  35.             return (t > 0 ? 1 : -1);
  36.         else if ('\0' == *a)
  37.             return (0);
  38.     }
  39.     return (0);
  40. }
  41. #endif
  42.  
  43. #ifdef NEED_STRDUP
  44. extern char * FAR
  45. strdup (register const char *s)
  46. {
  47.     char    *p;
  48.     int    len;
  49.  
  50.     if (F(s))
  51.         return (NULL);
  52.     
  53.     if (T(p = malloc (len = strlen (s) + 1)))
  54.         memcpy (p, s, len);
  55.     return (p);
  56. }
  57. #endif
  58.  
  59. #ifdef NEED_STRERROR
  60. extern char * FAR
  61. strerror (int n)
  62. {
  63.     static char    buf[30];
  64.  
  65.     sprintf (buf, "error is %d", n);
  66.     return (buf);
  67. }
  68. #endif
  69.  
  70. #ifdef NEED_LABS
  71. extern long FAR
  72. labs (long x)
  73. {
  74.     return (x<0 ? -x : x);
  75. }
  76. #endif
  77.